package com.example.njut;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class BallActivity extends AppCompatActivity {

    RelativeLayout root;
    public TextView xy;
    boolean flag = false;
    public static BallActivity ball;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ball);

        ball = this;
        root = (RelativeLayout)findViewById(R.id.root);
        xy = (TextView) findViewById(R.id.textView12);


        DrawView draw = new DrawView(this);
        draw.setMinimumHeight(650);
        draw.setMinimumWidth(400);
        root.addView(draw);
    }

    public void show(BallActivity ball){
        AlertDialog.Builder ab = new AlertDialog.Builder(BallActivity.this);
        ab.setIcon(R.mipmap.logo);
        ab.setTitle("恭喜！");
        ab.setMessage("您碰到了!");
        ab.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
               flag = false;
            }
        });
        ab.create();
        if(!flag){
            flag = true;
            ab.show();
        }else{
            return;
        }
    }
}
//每次碰到红球时，红球的半径变大10